<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "转入余额");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<style>
body{
	background-color: #f5f5f5;
}
.weui-cells {
	margin-top: 0px;
}
.weui-cell {
	background-color: white;
	color: #333333;
	padding: 15px;
}
.withdrawmoney>p {
	padding: 15px 10px;
	color: black;
	font-size: 16px;
}

.money {
	margin: 0px 10px;
	color: red;
}

#exchangeMoney {
	color: red;
}

.color-blue {
	color: #2196F3;
}

.bottom-btn {
	margin: 15px;
	padding: 2px;
	background-color: #2196F3;
}

.weui-btn_primary:not (.weui-btn_disabled ):active {
	background-color: #2196F3;
}

.weui-btn_disabled {
	background-color: #79c0f9 !important;
	color:
}

.weui-cell:before {
	border-top: 0px;
}

.share {
	border-bottom: 0px;
}

.service-award {
	border-top: 2px solid #eee;
}

#shareLevel {
	display: none;
}

.share-award {
	border-bottom: 0px;
}

.weui-cell_define {
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
	color: inherit
}

.weui-cell_define:active {
	background-color: #ececec
}

.weui-cell_define .weui-cell__ft {
	padding-right: 13px;
	position: relative
}

.weui-cell_define .weui-cell__ft:after {
	content: " ";
	display: inline-block;
	height: 6px;
	width: 6px;
	border-width: 0 2px 2px 0;
	border-color: #c8c8cd;
	border-style: solid;
	-webkit-transform: matrix(.71, .71, -.71, .71, 0, 0);
	transform: matrix(.71, .71, -.71, .71, 0, 0);
	position: relative;
	top: -2px;
	position: absolute;
	top: 50%;
	margin-top: -4px;
	right: 2px
}

	#money::-webkit-input-placeholder{
		color: #999;
	}
</style>

<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>

<div class="goback" data-back-href="<c:url value='/wechat/acc/myWealth/aboutIncome'/>"></div><div class="withdrawmoney">

<input type="hidden" class="moneyUser" value="${useIncome}">

<div style="background-color: #f5f5f5;padding: 1.3rem 15px">
	<p>
		<span style="color: #666666;">奖金：</span>
		<span style="color: #1fa0db;font-size: 1.5rem">
			￥<fmt:formatNumber value="${allIncome}" pattern="#.##" minFractionDigits="2" > </fmt:formatNumber>	
		</span>
	</p>
</div>

<div class="weui-cell">
	<div class="weui-cell__bd">
		<p>转出</p>
	</div>
</div>
<div class="weui-cell"  style="border-bottom: 1px solid #eee;border-bottom-left-radius: 0.2rem;border-bottom-right-radius: 0.2rem;padding-top: 0.2rem">
	<div class="weui-cell__hd">
		&nbsp;
	</div>
	<div class="weui-cell__bd">
		<input class="weui-input" id="money" type="number" placeholder="请输入转出金额" style="font-size: 18px;" onkeyup="btnColor(),checkMoney()"/>
	</div>
</div>
<span class="info" style="color: #ea693f; margin-left: 20px" hidden></span>
<div class="weui-cell">
	<div class="weui-cell__bd">
		<p>可用奖金：
		<span class="userMoney">
			<fmt:formatNumber type="number" value="${useIncome}"  pattern="#.##" minFractionDigits="2" />
		</span>
		元</p>
	</div>
	<div class="weui-cell__ft" style="color: #1fa0db" onclick="withdrawals()" >
		 全部转余额
	</div>
</div>
<div style="width: 100%; height: 10px; background-color: #f5f5f5;"></div>
<div class="weui-cell"style="border-bottom: 2px solid #eee;font-size: 18px">
	<div class="weui-cell__hd"></div>
	<div class="weui-cell__bd">
		<p>
			<span>不可用奖金：</span> 
				<fmt:formatNumber type="number" value="${uselessIncome}" pattern="#.##" minFractionDigits="2" />
			<span>元</span>
		</p>
	</div>
	<div class="weui-cell__ft" style="color: #1fa0db">详情</div>
</div>	
<div style="z-index: 500;">
	<a href="javascript:withdraw();"data-href="<c:url value='/wechat/acc/myWealth/myWealth'/>"class="weui-btn weui-btn_primary bottom-btn withdraw weui-btn_disabled"id="btn">转&nbsp;&nbsp;&nbsp;&nbsp;入</a>
</div>
	
<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/tabmob.jsp"%>

<script type="text/javascript">
//点击转入按钮要执行的操作 
function withdraw() {
	if (!checkInput()) {
		return;
	}
	
	var money = $("#money").val();
	var action = $.getVirtualPath()+"/wechat/acc/myWealth/doIncomeToBalance?money="+money;
	var result = $.getTextPost(action);
	if (result == "true") {
		$.toast("转入余额成功");
		setTimeout(function() {
			window.location.href = $.getVirtualPath()+"/wechat/acc/myWealth/myWealth";
		}, 500);
	} else {
		$.toast("转入余额失败", "forbidden");
	}
}

function btnColor() {
	var $withdraw = $(".withdraw");
	var $money = $("#money");
	var value = $money.val();
	if (value != '') {
		$("#btn").attr("disabled", false); 
		if ($withdraw.attr("class").indexOf("weui-btn_disabled") > 0) {
			$withdraw.removeClass("weui-btn_disabled");	
		}
	}
	if (value == ''|| value ==0) {
		$("#btn").attr("disabled", true); 
		$withdraw.addClass("weui-btn_disabled");			
	}
}

/* 检查输入 */
function checkInput() {
	if (checkMoney()) {
		return true;
	}
	return false;
}
/* 检查是否输入金额 */
function checkMoney() {
	var money = $("#money").val();
	
	var reg = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0){1}$)|(^\d\.\d{1,2}?$)/; 
	if (money == ''|| money == '0' || money == '0.0' ||  money == '0.00') {
		$("#btn").attr("disabled", false);
		$(".info").hide();
		return false;
	}
	else if(!reg.test(money)){
		$(".info").html("请输入正确金额数");
		$(".info").show();
		var $withdraw = $(".withdraw");
		$withdraw.addClass("weui-btn_disabled");
		
		/* $.toptip("请输入正确的金额","error"); */
		return false;
	}
	
	var allmoney =$(".userMoney").html();
	if( parseFloat(money)>parseFloat(allmoney)){
		$(".info").html("转入奖金超出可用奖金");
		$(".info").show();
		var $withdraw = $(".withdraw");
		$withdraw.addClass("weui-btn_disabled");
		return false;
	}
	$(".info").hide();
	return true;
}
//全部提现的实现
function withdrawals(){		
	var allmoney = $(".moneyUser").val();
	$("#money").val(allmoney);
	btnColor();
	
} 

</script>
